package com.jmz.qyyl.mapper;

import com.jmz.qyyl.domain.URole;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
/**
 * 功能描述: <br>
 * 〈〉
 * @since: 1.0.0
 * @Author:zmy
 * @Date: 2018/3/3 上午12:31
 */
public interface URoleMapper {
    @Delete({
        "delete from u_role",
        "where id = #{id,jdbcType=BIGINT}"
    })
    /**
     * 功能描述: <br>
     * 〈〉
     *
     * @param id
     * @return:int
     * @since: 1.0.0
     * @Author:zmy
     * @Date: 2018/3/3 上午12:28
     */
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into u_role (name, type)",
        "values (#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)

    /**
     * 功能描述: <br>
     * 〈〉
     *
     * @param record
     * @return:java.lang.Long
     * @since: 1.0.0
     * @Author:zmy
     * @Date: 2018/3/3 上午12:29
     */
    Long insert(URole record);

    @Select({
        "select",
        "id, name, type",
        "from u_role",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType= JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType= JdbcType.VARCHAR)
    })
    /**
     * 功能描述: <br>
     * 〈〉
     *
     * @param id
     * @return:com.jmz.qyyl.domain.URole
     * @since: 1.0.0
     * @Author:zmy
     * @Date: 2018/3/3 上午12:30
     */
    URole selectByPrimaryKey(Long id);

    @Select({
        "select",
        "id, name, type",
        "from u_role"
    })
    @Results({
        @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType= JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType= JdbcType.VARCHAR)
    })
    /**
     * 功能描述: <br>
     * 〈〉
     *
     * @param
     * @return:java.util.List<com.jmz.qyyl.domain.URole>
     * @since: 1.0.0
     * @Author:zmy
     * @Date: 2018/3/3 上午12:30
     */
    List<URole> selectAll();

    @Update({
        "update u_role",
        "set name = #{name,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    /**
     * 功能描述: <br>
     * 〈〉
     *
     * @param record
     * @return:int
     * @since: 1.0.0
     * @Author:zmy
     * @Date: 2018/3/3 上午12:30
     */
    int updateByPrimaryKey(URole record);
}